class Single {
  constructor() {
    console.log('constructor~')
    // 会死循环
    // if(!Single.instance)
    //   Single.instance = new Single()
    // return Single.instance
  }
  static getInstance() {
    return Single.instance ||  (Single.instance = new Single())
  }
}

let sg = new Single()
// console.log(Single.getInstance() === sg)